package com.spring.collectiondemo;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.PropertySources;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Apps {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
		ComplexObject obj = context.getBean("moreComplexObject", ComplexObject.class);
		Properties adminEmails = obj.getAdminEmails();
		List someList = obj.getSomeList();
		Map someMap = obj.getSomeMap();
		Set someSet = obj.getSomeSet();
		System.out.println(adminEmails);

		PropertySourcesPlaceholderConfigurer myDataSource = (PropertySourcesPlaceholderConfigurer) context.getBean("myDataSource");
		PropertySources sources = myDataSource.getAppliedPropertySources();
		PropertySource<?> localProperties = sources.get("localProperties");
		String propertySource = (String) localProperties.getProperty("jdbc.driver.className");
		System.out.println(propertySource);
	}
}
